﻿using System;
using System.Collections;
using System.Runtime.Serialization;
using System.Web;

namespace NWebMock
{
    public class HttpApplicationStateWrapper : IHttpApplicationState
    {
        #region Constructors

        public HttpApplicationStateWrapper(HttpApplicationState application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            this.innerApplication = application;
        }

        #endregion

        #region Fields

        private HttpApplicationState innerApplication = null;

        #endregion

        #region Properties

        public string[] AllKeys { get { return this.innerApplication.AllKeys; } }

        public HttpApplicationState Contents { get { return this.innerApplication.Contents; } }

        public int Count { get { return this.innerApplication.Count; } }

        public object this[int index] { get { return this.innerApplication[index]; } }

        public object this[string name] { get { return this.innerApplication[name]; } set { this.innerApplication[name] = value; } }

        public ICollection Keys { get { return this.innerApplication.Keys; } }

        public ICollection StaticObjects { get { return this.innerApplication.StaticObjects; } }

        #endregion

        #region Methods

        public void Add(string name, object value)
        {
            this.innerApplication.Add(name, value);
        }

        public void Clear()
        {
            this.innerApplication.Clear();
        }

        public object Get(int index)
        {
            return this.innerApplication.Get(index);
        }

        public object Get(string name)
        {
            return this.innerApplication.Get(name);
        }

        public IEnumerator GetEnumerator()
        {
            return this.innerApplication.GetEnumerator();
        }

        public string GetKey(int index)
        {
            return this.innerApplication.GetKey(index);
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            this.innerApplication.GetObjectData(info, context);
        }

        public void Lock()
        {
            this.innerApplication.Lock();
        }

        public void OnDeserialization(object sender)
        {
            this.innerApplication.OnDeserialization(sender);
        }

        public void Remove(string name)
        {
            this.innerApplication.Remove(name);
        }

        public void RemoveAll()
        {
            this.innerApplication.RemoveAll();
        }

        public void RemoveAt(int index)
        {
            this.innerApplication.RemoveAt(index);
        }

        public void Set(string name, object value)
        {
            this.innerApplication.Set(name, value);
        }

        public void UnLock()
        {
            this.innerApplication.UnLock();
        }

        #endregion

        #region ICollection Members

        void ICollection.CopyTo(Array array, int index)
        {
            ((ICollection)this.innerApplication).CopyTo(array, index);
        }

        bool ICollection.IsSynchronized { get { return ((ICollection)this.innerApplication).IsSynchronized; } }

        object ICollection.SyncRoot { get { return ((ICollection)this.innerApplication).SyncRoot; } }

        #endregion
    }
}
